{$cleo .cs}

model.Load(9093)
038B: load_requested_models

const
_KEY_CARD = 20@
_GATE_OPEN1 = 21@
_GATE_OPEN2 = 22@
_GATE_OPEN3 = 23@
_GATE_OPEN4 = 24@
_GATE_OPEN5 = 25@
_GATE_OPEN6 = 26@
_GATE_OPEN7 = 27@
_GATE_OPEN8 = 28@
_GATE_OPEN9 = 29@
_GATE_OPEN10 = 19@

end
_GATE_OPEN1 = 0
_GATE_OPEN2 = 0
_GATE_OPEN3 = 0
_GATE_OPEN4 = 0
_GATE_OPEN5 = 0
_GATE_OPEN6 = 0
_GATE_OPEN7 = 0
_GATE_OPEN8 = 0
_GATE_OPEN9 = 0
_GATE_OPEN10 = 0

_KEY_CARD = 0
33@ = 0 
32@ = 0



029B: 0@ = init_object 9093 at 1911.92 -4350.3701 6.04 // object  GATE open right enter lab
0453: set_object 0@ XY_rotation 90.0 0.0 angle 269.995
029B: 1@ = init_object 9093 at 1908.38 -4350.3901 6.19 // object (gate open left enter lab
0453: set_object 1@ XY_rotation 90.0 0.0 angle 89.995


029B: 2@ = init_object 9093 at 1958.92 -4323.1602 6.91 // object (gate open right SR2 PCs
0453: set_object 2@ XY_rotation 90.0 0.0 angle 269.984
029B: 3@ = init_object 9093 at 1955.38 -4323.1699 6.91 // object (gate open left SR2 lab pc room
0453: set_object 3@ XY_rotation 90.0 0.0 angle 89.984     

029B: 4@ = init_object 9093 at 1929.74 -4311.4502 5.19 // object gate open left stairway
0453: set_object 4@ XY_rotation 90.0 0.0 angle 89.984
029B: 5@ = init_object 9093 at 1933.29 -4311.4302 5.12 // object (gate open right to pump stairway
0453: set_object 5@ XY_rotation 90.0 0.0 angle 269.984

029B: 6@ = init_object 9093 at 1928.8101 -4272.52 5.14 // object  gate open right to PUMPS
0453: set_object 6@ XY_rotation 90.0 0.0 angle 269.984
029B: 7@ = init_object 9093 at 1925.26 -4272.5498 5.21 // object (gate open left to PUMPS
0453: set_object 7@ XY_rotation 90.0 0.0 angle 89.984

029B: 8@ = init_object 9093 at 1907.8199 -4278.5098 6.26 // object (gate open right to stairway exit
0453: set_object 8@ XY_rotation 90.0 0.0 angle 269.984
029B: 9@ = init_object 9093 at 1904.29 -4278.54 6.23 // object (gate left open to stairway exit
0453: set_object 9@ XY_rotation 90.0 0.0 angle 89.984
029B: 10@ = init_object 9093 at 1918.6801 -4337.1499 5.2 // object (gate open left create luigi room where SR2
0453: set_object 10@ XY_rotation 90.0 0.0 angle 359.984
029B: 11@ = init_object 9093 at 1918.7 -4340.6699 5.13 // object gate open to another create right
0453: set_object 11@ XY_rotation 90.0 0.0 angle 179.984

029B: 30@ = init_object 985 at 1828.33 -4227.21 17.59 // object Restricted GAte open just deleted it
0453: set_object 30@ XY_rotation 0.0 0.0 angle 270.0
04D9: object 0@ set_scripted_collision_check 0
04D9: object 1@ set_scripted_collision_check 0
04D9: object 2@ set_scripted_collision_check 0
04D9: object 3@ set_scripted_collision_check 0
04D9: object 4@ set_scripted_collision_check 0
04D9: object 5@ set_scripted_collision_check 0
04D9: object 6@ set_scripted_collision_check 0
04D9: object 7@ set_scripted_collision_check 0
04D9: object 8@ set_scripted_collision_check 0
04D9: object 9@ set_scripted_collision_check 0
04D9: object 10@ set_scripted_collision_check 0
04D9: object 11@ set_scripted_collision_check 0
04D9: object 30@ set_scripted_collision_check 0



:main
wait 0
GOSUB @open_gates
gosub @reset_gates
gosub @close_gates
if
$onmission == 0
then
object.Destroy(0@)
object.Destroy(1@)
object.Destroy(2@)
object.Destroy(3@)
object.Destroy(4@)
object.Destroy(5@)
object.Destroy(6@)
object.Destroy(7@)
object.Destroy(8@)
object.Destroy(9@)
object.Destroy(10@)
object.Destroy(11@)
object.Destroy(30@)

enD_thread
end
jump @main

:open_gates     
gosub @random_actors {
if
_KEY_CARD == 0
then
_KEY_CARD = 1   }
if  and
_GATE_OPEN1 == 0
056D:   actor 31@ defined
then
if
0474:   actor 31@ near_object_in_cube 0@ radius 3.0 3.0 2.0 sphere 0
then
_GATE_OPEN1 = 1
32@ = 0
//marker.CreateAboveObject($test2, 0@)
//015F: set_camera_position  1910.202 -4358.3042 5.1388 rotation 0.0 0.0 0.0
////0160: set_camera_point_at  1909.9526 -4352.1431 5.1388 switchstyle 2


0392: make_object 0@ moveable 1
0381: throw_object 0@ velocity_in_direction 2.0 0.0 0.0 

0392: make_object 1@ moveable 1
0381: throw_object 1@ velocity_in_direction -2.0 0.0 0.0 

end
end
:SR2_LABS
if  and
_GATE_OPEN2 == 0
056D:   actor 31@ defined        
then
if
0474:   actor 31@ near_object_in_cube 2@ radius 3.0 3.0 2.0 sphere 0
then
_GATE_OPEN2 = 1
32@ = 0

//015F: set_camera_position  1910.202 -4358.3042 5.1388 rotation 0.0 0.0 0.0
////0160: set_camera_point_at  1909.9526 -4352.1431 5.1388 switchstyle 2


0392: make_object 2@ moveable 1
0381: throw_object 2@ velocity_in_direction 2.0 0.0 0.0 

0392: make_object 3@ moveable 1
0381: throw_object 3@ velocity_in_direction -2.0 0.0 0.0 
end
end
if   and
_GATE_OPEN3 == 0
056D:   actor 31@ defined
then

if
0474:   actor 31@ near_object_in_cube 4@ radius 3.0 3.0 2.0 sphere 0
then
_GATE_OPEN3 = 1
32@ = 0

//015F: set_camera_position  1910.202 -4358.3042 5.1388 rotation 0.0 0.0 0.0
////0160: set_camera_point_at  1909.9526 -4352.1431 5.1388 switchstyle 2


0392: make_object 4@ moveable 1
0381: throw_object 4@ velocity_in_direction -2.0 0.0 0.0 

0392: make_object 5@ moveable 1
0381: throw_object 5@ velocity_in_direction 2.0 0.0 0.0 
end
end
if  and
_GATE_OPEN4 == 0
056D:   actor 31@ defined         //open gate
then

if
0474:   actor 31@ near_object_in_cube 6@ radius 3.0 3.0 2.0 sphere 0
then
_GATE_OPEN4 = 1
32@ = 0

0392: make_object 6@ moveable 1
0381: throw_object 6@ velocity_in_direction 2.0 0.0 0.0 

0392: make_object 7@ moveable 1
0381: throw_object 7@ velocity_in_direction -2.0 0.0 0.0 
end
end


return

:close_gates
if and
_GATE_OPEN1 == 1
32@ > 2000
then
33@ = 0

0392: make_object 0@ moveable 1
0381: throw_object 0@ velocity_in_direction -2.0 0.0 0.0 

0392: make_object 1@ moveable 1
0381: throw_object 1@ velocity_in_direction 2.0 0.0 0.0 
_GATE_OPEN1 = 0
end

if and
_GATE_OPEN2 == 1
32@ > 2000
then
33@ = 0

0392: make_object 2@ moveable 1
0381: throw_object 2@ velocity_in_direction -2.0 0.0 0.0 

0392: make_object 3@ moveable 1
0381: throw_object 3@ velocity_in_direction 2.0 0.0 0.0 
_GATE_OPEN2 = 0
end
if and
_GATE_OPEN3 == 1
32@ > 2000
then
33@ = 0                                   //close back

0392: make_object 4@ moveable 1
0381: throw_object 4@ velocity_in_direction 2.0 0.0 0.0 

0392: make_object 5@ moveable 1
0381: throw_object 5@ velocity_in_direction -2.0 0.0 0.0 
_GATE_OPEN3 = 0
end

if and
_GATE_OPEN4 == 1
32@ > 2000
then
33@ = 0                                   //close back

0392: make_object 6@ moveable 1
0381: throw_object 6@ velocity_in_direction 2.0 0.0 0.0 

0392: make_object 7@ moveable 1
0381: throw_object 7@ velocity_in_direction -2.0 0.0 0.0 
_GATE_OPEN4 = 0
end
return



:reset_gates
if and
33@ > 2000
_GATE_OPEN1 == 0
then                       
0815:  put_object 1@ at  1908.38 -4350.3901 6.19 
0815:  put_object 0@ at  1911.92 -4350.3701 6.04 
33@ = 0
//32@ = 0

end
if and
33@ > 2000
_GATE_OPEN2 == 0
then                       
0815:  put_object 2@ at  1958.92 -4323.1602 6.91 
0815:  put_object 3@ at  1955.38 -4323.1699 6.91
33@ = 0
//32@ = 0
end
if and
33@ > 2000
_GATE_OPEN3 == 0
then                       
0815:  put_object 4@ at  1929.74 -4311.4502 5.19
0815:  put_object 5@ at 1933.29 -4311.4302 5.12
33@ = 0
//32@ = 0
end
if and
33@ > 2000
_GATE_OPEN4 == 0
then                       
0815:  put_object 6@ at 1928.8101 -4272.52 5.14 
0815:  put_object 7@ at 1925.26 -4272.5498 5.21
//0815: put_object 7@ at 20@ 21@ 22@ and_keep_rotation

33@ = 0
//32@ = 0
end
return
//029B: 6@ = init_object 9093 at 1928.8101 -4272.52 5.14 // object  gate open right to PUMPS
//0453: set_object 6@ XY_rotation 90.0 0.0 angle 269.984
//029B: 7@ = init_object 9093 at 1925.26 -4272.5498 5.21 // object (gate open left to PUMPS
//0453: set_object 7@ XY_rotation 90.0 0.0 angle 89.984


//029B: 4@ = init_object 9093 at 1929.74 -4311.4502 5.19 // object gate open left stairway
//0453: set_object 4@ XY_rotation 90.0 0.0 angle 89.984
//029B: 5@ = init_object 9093 at 1933.29 -4311.4302 5.12 // object (gate open right to pump stairway
//0453: set_object 5@ XY_rotation 90.0 0.0 angle 269.984



:random_actors
0209: 18@ = random_int_in_ranges 0 3
if
18@ == 0
then
0AE1: 31@ = random_actor_near_point 1897.5699 -4178.52 19.22 in_radius 850.0 find_next 1 pass_deads 1

end
if
18@ == 1
then
31@ = actor.EmulateFromPlayer($PLAYER_CHAR)
end
if
18@ == 2
then
if
056D:   actor $SECOND_PLAYER_ACTOR defined
then
31@ = actor.EmulateFromPlayer($SECOND_PLAYER)
end
end

return